<template>
  <div class="home">
    <DynamicTable 
      :fields="fields" 
      :tableData="tableData"
      @update:tableSelectedChange="val => tableSelectedArr = val">
      <template v-slot:selection>
        <el-table-column type="selection" width="55"></el-table-column>
      </template>
      <template v-slot:index>
        <el-table-column type="index"></el-table-column>
      </template>
      <template v-slot:operation>
        <el-table-column label="操作" width="200">
          <template slot-scope="scope">
            <el-button type="text" size="small" @click="handleClick(scope.row)">查看</el-button>
            <el-button type="text" size="small">编辑</el-button>
          </template>
        </el-table-column>
      </template>
    </DynamicTable>
  </div>
</template>

<script>
export default {
  data(){
    return {
      tableSelectedArr:[],
      fields:[
        {
          label:'单位',
          key:'cor'
        },{
          label:'姓名',
          key:'name'
        }
      ],
      tableData:[
        {
          cor:'微软',
          name:'王'
        },{
          cor:'微软',
          name:'王'
        }
      ]
    }
  },
  methods:{
    handleClick(row){
      console.log(row,this.tableSelectedArr)
    }
  },
  mounted(){
  
  }
}
</script>